#include "UIInstruction.h"

std::unordered_map<std::string, std::shared_ptr<UIInstruction>> UIInstruction::instructionMap;

void UIInstruction::RegisterInstruction(std::shared_ptr<UIInstruction> inst)
{
    instructionMap.insert(make_pair(inst->GetInstName(), inst));
}

std::string UIInstruction::GetHelp()
{
    std::string usage;
    if (!this->GetArgs().empty()) {
        usage = usage + "\n      " + "usage:    " + this->GetInstName() + " " + this->GetArgs();
    }
    char buf[1024];
    sprintf(buf, "%-14s %s%s", instName.c_str(), helpInfo.c_str(), usage.c_str());
    return std::string(buf);
}